home *** CD-ROM | disk | FTP | other *** search
/ Shirley Barber's Fairies: Create, Paint & Play / Fairies.iso / pc / Files / ColourIn.dxr / Internal_16_Jump to Movie.ls < prev    next >
Encoding:
Text File  |  2003-09-29  |  5.6 KB  |  153 lines

  1. property getPDLError, myBehaviorName, myDistantMovie, myDistantMarker, myJumpMode, myReturn, myTurnOffAllSounds
  2.  
  3. on beginSprite me
  4.   Initialize(me)
  5. end
  6.  
  7. on mouseUp me
  8.   jump(me)
  9. end
  10.  
  11. on Initialize me
  12.   global gNavigationButtonList
  13.   myBehaviorName = string(me)
  14.   delete word 1 of myBehaviorName
  15.   delete char -30001 of myBehaviorName
  16.   delete char -30001 of myBehaviorName
  17.   if myReturn then
  18.     if voidp(gNavigationButtonList) then
  19.       gNavigationButtonList = [#stack: [], #forward: [], #index: []]
  20.     else
  21.       if gNavigationButtonList.ilk <> #propList then
  22.         ErrorAlert(me, #invalidGlobal, gNavigationButtonList)
  23.       else
  24.         if not gNavigationButtonList.findPos(#stack) then
  25.           ErrorAlert(me, #invalidGlobal, gNavigationButtonList)
  26.         else
  27.           if not gNavigationButtonList.findPos(#index) then
  28.             ErrorAlert(me, #invalidGlobal, gNavigationButtonList)
  29.           else
  30.             if not gNavigationButtonList.findPos(#forward) then
  31.               ErrorAlert(me, #invalidGlobal, gNavigationButtonList)
  32.             end if
  33.           end if
  34.         end if
  35.       end if
  36.     end if
  37.   end if
  38.   case myDistantMarker of
  39.     EMPTY, " ":
  40.       myDistantMarker = 0
  41.   end case
  42. end
  43.  
  44. on jump me
  45.   global gNavigationButtonList
  46.   if myTurnOffAllSounds then
  47.     sound(1).stop()
  48.     sound(2).stop()
  49.     sound(3).stop()
  50.     sound(4).stop()
  51.     sound(5).stop()
  52.     sound(6).stop()
  53.   end if
  54.   currentMarker = [#frame: marker(0), #movie: the movieName]
  55.   if myReturn then
  56.     gNavigationButtonList.stack.append(currentMarker)
  57.     if not gNavigationButtonList.index.getPos(currentMarker) then
  58.       gNavigationButtonList.index.append(currentMarker)
  59.     end if
  60.     gNavigationButtonList.forward = []
  61.   end if
  62.   if myJumpMode = "Go to" then
  63.     go(marker(myDistantMarker), myDistantMovie)
  64.   else
  65.     play frame marker(myDistantMarker) of movie myDistantMovie
  66.   end if
  67.   if the movieName = myDistantMovie then
  68.     if the frameLabel <> myDistantMarker then
  69.       ErrorAlert(me, #invalidMarker, currentMarker)
  70.     end if
  71.   end if
  72. end
  73.  
  74. on substituteStrings me, parentString, childStringList
  75.   i = childStringList.count()
  76.   repeat while i
  77.     tempString = EMPTY
  78.     dummyString = childStringList.getPropAt(i)
  79.     replacement = childStringList[i]
  80.     lengthAdjust = dummyString.char.count - 1
  81.     repeat while 1
  82.       position = offset(dummyString, parentString)
  83.       if not position then
  84.         parentString = tempString & parentString
  85.         exit repeat
  86.         next repeat
  87.       end if
  88.       if position <> 1 then
  89.         tempString = tempString & parentString.char[1..position - 1]
  90.       end if
  91.       tempString = tempString & replacement
  92.       delete parentString.char[1..position + lengthAdjust]
  93.     end repeat
  94.     i = i - 1
  95.   end repeat
  96.   return parentString
  97. end
  98.  
  99. on ErrorAlert me, theError, Data
  100.   behaviorName = string(me)
  101.   delete word 1 of behaviorName
  102.   delete char -30001 of behaviorName
  103.   delete char -30001 of behaviorName
  104.   case Data.ilk of
  105.     #void:
  106.       Data = "<void>"
  107.     #symbol:
  108.       Data = "#" & Data
  109.   end case
  110.   case theError of
  111.     #getPDL_Invalid:
  112.       terror1 = "BEHAVIOR ERROR: Frame ^0, Sprite ^1"
  113.       terror1 = substituteStrings(me, terror1, ["^0": the frame, "^1": the currentSpriteNum])
  114.       terror2 = "Parameters for behavior ^0 have not been correctly set. " & "Select a valid movie name in the Behavior Parameters dialog."
  115.       terror2 = substituteStrings(me, terror2, ["^0": myBehaviorName])
  116.       terror3 = "Current movie = ^0"
  117.       terror3 = substituteStrings(me, terror3, ["^0": Data])
  118.       alert(terror1 & RETURN & RETURN & terror2 & RETURN & RETURN & terror3)
  119.       halt()
  120.     #invalidGlobal:
  121.       terror1 = "BEHAVIOR ERROR: Frame ^0, Sprite ^1"
  122.       terror1 = substituteStrings(me, terror1, ["^0": the frame, "^1": the currentSpriteNum])
  123.       terror2 = "Behavior ^0 requires a global gNavigationButtonList with the following" & RETURN & " structure:"
  124.       terror2 = substituteStrings(me, terror2, ["^0": myBehaviorName])
  125.       terror3 = "[#stack [...], #index: [...], #forward: [...]]"
  126.       tError4 = "Current value = ^0"
  127.       tError4 = substituteStrings(me, tError4, ["^0": Data])
  128.       alert(terror1 & RETURN & RETURN & terror2 & RETURN & RETURN & terror3 & RETURN & RETURN & tError4)
  129.       abort()
  130.     #invalidMarker:
  131.       if the runMode = "Author" then
  132.         terror1 = "BEHAVIOR ERROR: ^0, Sprite ^1"
  133.         terror1 = substituteStrings(me, terror1, ["^0": Data, "^1": the currentSpriteNum])
  134.         terror2 = "Behavior ^0"
  135.         terror2 = substituteStrings(me, terror2, ["^0": myBehaviorName])
  136.         terror3 = "There is no marker ^0 in movie ^1. " & "Enter a valid marker (see Message Window) in the Behavior Parameters dialog."
  137.         terror3 = substituteStrings(me, terror3, ["^0": QUOTE & myDistantMarker & QUOTE, "^1": myDistantMovie])
  138.         alert(terror1 & RETURN & RETURN & terror2 & RETURN & RETURN & terror3)
  139.       end if
  140.   end case
  141. end
  142.  
  143. on isOKToAttach me, aSpriteType, aSpriteNum
  144.   return aSpriteType = #graphic
  145. end
  146.  
  147. on getPropertyDescriptionList me
  148.   if not (the currentSpriteNum) then
  149.     exit
  150.   end if
  151.   return [#myDistantMovie: [#comment: "On mouseUp, go to movie" & RETURN & "(Include path if necessary)", #format: #string, #default: "Type the name of your movie here"], #myDistantMarker: [#comment: "Marker in the other movie (optional)", #format: #string, #default: " "], #myJumpMode: [#comment: "Jump Mode", #format: #string, #range: ["Go to", "Play and Return"], #default: "Go to"], #myReturn: [#comment: "Remember current marker for Back button?", #format: #boolean, #default: 1], #myTurnOffAllSounds: [#comment: "Turn off all sounds before jumping?", #format: #boolean, #default: 1]]
  152. end
  153.